<!--
 * @Author: 李天惊 uf_lee@163.com
 * @Date: 2022-08-24 13:22:19
 * @LastEditors: 李小晴 2689279066@qq.com
 * @LastEditTime: 2023-08-13 17:18:39
 * @FilePath: \ahbs\uc_sys\src\views\System\App\components\See.vue
 * Copyright (c) 2022 by 李天惊 uf_lee@163.com, All Rights Reserved. 
-->
<script setup lang="ts">
import { PropType } from 'vue'
import { ElImage } from 'element-plus'
import { Descriptions } from '@/components/Descriptions'
import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()
const dict: any = wsCache.get('dict')
const props = defineProps({
  currentRow: {
    type: Object as PropType<Nullable<any>>,
    default: () => null
  },
  detailSchema: {
    type: Array as PropType<DescriptionsSchema[]>,
    default: () => []
  }
})

// 字典通过value获取label
const getDictLabel = (type, value) => {
  let data = dict[type].find((item) => {
    return item.value == value
  })
  return data ? data.label : ''
}
console.log(props, 'props')
</script>

<template>
  <Descriptions :schema="detailSchema" :data="currentRow || {}">
    <template #images="{ row }">
      <ElImage v-if="row.file_type == 1" :src="row.file_url" />
      <span v-else>{{ row.file_url }}</span>
    </template>
    <template #belong_type="{ row }">
      <div>{{ getDictLabel('belong_type', row.belong_type) }}</div>
    </template>
    <template #file_type="{ row }: { row: any }">
      <div>{{ getDictLabel('file_type', row.file_type) }}</div>
    </template>
    <template #file_size="{ row }">
      <span>{{ row.file_size + `KB` }}</span>
    </template>
  </Descriptions>
</template>
